//
//  NSRegularExpression+Extension.m
//  SinaWebo
//
//  Created by wwj on 16/5/19.
//  Copyright © 2016年 亦心. All rights reserved.
//

#import "NSRegularExpression+Extension.h"

@implementation NSRegularExpression (Extension)

+ (instancetype)regexEmoticon{
    NSString *pattern = @"\\[.*?\\]";
    NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:kNilOptions error:nil];
    return regex;
}

+ (instancetype)regexTopic{
    NSString *pattern = @"#[^@#]+?#";
    NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:kNilOptions error:nil];
    return regex;
}

+ (instancetype)regexAt{
    NSString *pattern = @"@[-_a-zA-Z0-9\u4E00-\u9FA5]+";
    NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:kNilOptions error:nil];
    return regex;
}

+ (instancetype)regexURL{
    NSString *pattern = @"http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?";
    NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:kNilOptions error:nil];
    return regex;
}
@end
